package com.javaframe.role.tools;

import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.SessionFactoryUtils;

public class OpenSessionInViewFilter extends
		org.springframework.orm.hibernate3.support.OpenSessionInViewFilter {
        protected Session getSession(SessionFactory sessionFactory){
        	Session session=SessionFactoryUtils.getSession(sessionFactory, true);
        	session.setFlushMode(FlushMode.COMMIT);
			return session;
        }
        
        protected void closeSession(Session session, SessionFactory sessionFactory){
        	session.flush();
        	super.closeSession(session, sessionFactory);
        }
}
